package com.market.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Description TODO
 * @Author 1
 * @Date 2022/4/3 20:39
 * @Version 1.0
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    BuyerInterceptor buyerInterceptor;
    @Autowired
    ManagerInterceptor managerInterceptor;
    @Autowired
    CSStaffInterceptor csStaffInterceptor;
    @Autowired
    SorterInterceptor sorterInterceptor;
    @Autowired
    IntoStorageInterceptor intoStorageInterceptor;
    @Autowired
    SuperManagerInterceptor superManagerInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //买家权限拦截
        registry
                .addInterceptor(buyerInterceptor)
                .addPathPatterns("/buyer/*")
                .excludePathPatterns("/buyer/buyerLoginByUserNameAndPwd","/buyer/buyerRegisterByAccountAndPwd","/buyer/sendCode","/buyer/buyerRegisterByCode/{code}");
        
        //管理员权限拦截
        registry
                .addInterceptor(managerInterceptor)
                .addPathPatterns("/backstage/admin/queryBackstage")
                .addPathPatterns("/backstage/admin/queryBuyerInfo")
                .addPathPatterns("/backstage/admin/queryAllBackstage")
                .addPathPatterns("/backstage/admin/queryAllBuyer")
                .addPathPatterns("/backstage/admin/lockBuyer")
                .addPathPatterns("/backstage/admin/unLockBuyer")
                .addPathPatterns("/backstage/admin/lockBackstage")
                .addPathPatterns("/backstage/admin/unLockBackstage")
                .addPathPatterns("/backstage/admin/addGoods")
                .addPathPatterns("/backstage/admin/shelveGoods")
                .addPathPatterns("/backstage/admin/offShelveGoods")
                .addPathPatterns("/backstage/admin/deleteGoods")
                .addPathPatterns("/backstage/admin/queryGoodsByGoodsId")
                .addPathPatterns("/backstage/admin/queryOrder")
                .addPathPatterns("/backstage/admin/queryAllOrder")
                .addPathPatterns("/backstage/admin/addGoodsType")
                .addPathPatterns("/backstage/admin/deleteOrder")
                .addPathPatterns("/backstage/admin/queryTodayAlreadyPaidOrder")
                .addPathPatterns("/backstage/admin/queryBuyerCashFlow")
                .addPathPatterns("/backstage/admin/updateGoodsSellNum")
                .addPathPatterns("/backstage/admin/queryBackstageByAccount")
                .addPathPatterns("/backstage/admin/queryAllSendBack")
        ;


        //超级管理员权限拦截
        registry
                .addInterceptor(superManagerInterceptor)
                .addPathPatterns("/backstage/admin/addBackStageUser")
                .addPathPatterns("/backstage/admin/updateRole")
        ;
        //客服人员权限拦截
        registry
                .addInterceptor(csStaffInterceptor)
                .addPathPatterns("backstage/CSStaff/checkStore")
                .addPathPatterns("backstage/CSStaff/checkSendBackGoods")
                ;
        //分拣员权限拦截
        registry
                .addInterceptor(sorterInterceptor)
                .addPathPatterns("backstage/sorter/printTodaySortRecord")
        ;
        //入库员入库
        registry
                .addInterceptor(intoStorageInterceptor)
                .addPathPatterns("backstage/intoStorage/goodsIntoStorage");
    }
}
